package com.qf.cx.simplenms.persist.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.qf.cx.simplenms.persist.dao.api.TopicDao;
import com.qf.cx.simplenms.persist.entity.TopicEntity;
import com.qf.cx.simplenms.persist.service.api.TopicService;

@Service
@Transactional(value = "hibernateTransactionManager")
public class TopicServiceImpl implements TopicService {
	@Autowired
	private TopicDao topicDao;

	@Override
	public void addTopic(TopicEntity topic) {
		topicDao.addTopic(topic);
	}

	@Override
	public void deleteTopic(String name) {
		topicDao.deleteTopic(name);
	}

	@Override
	public void updateTopic(TopicEntity topic) {
		topicDao.updateTopic(topic);
	}

	@Override
	public TopicEntity getTopic(String name) {
		TopicEntity topic = topicDao.getTopic(name);
		return topic;
	}

	@Override
	public List<TopicEntity> getTopics() {
		List<TopicEntity> list = topicDao.getTopics();
		return list;
	}

	@Override
	public void addTopics(List<TopicEntity> topicEntities) {
		topicEntities.forEach(t -> addTopic(t));
	}

}
